<!doctype html>
<html style="font-size: 55.2px;">
<head design-width="750">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <title>账号管理</title>
    <link rel="stylesheet" href="__CDN__/assets/userinfo/css/style.css"><!--页面样式-->

    <script src="__CDN__/assets/userinfo/js/auto-size.js"></script><!--设置字体大小-->

    <script src="__CDN__/assets/userinfo/js/jquery-2.2.4.min.js"></script><!--设置字体大小-->

</head>
<body>
<div class="mobile-wrap center mobile-wrap-mb">

    <header>
        	<span class="return">
                <a class="back-btn" href="javascript:history.go(-1)">
                    返回
                </a>
        	</span>
    </header>
    <main>
        <div class="inform">
            <h3>账号管理</h3>
            <div class="inform-list">
                <ul>
                    <li class="acti">实名认证</li>
                    <li>修改资料</li>
                    <li>修改密码</li>
                </ul>
            </div>
            <div class="inform-text show">
                <form id="renzheng" onsubmit="return false" action="##" method="post">

                {if condition="$row.real_name == NULL"}
                    <p>
                            <span>
                                真实姓名
                            </span>
                        <input type="text" name="name" value="{$row.real_name}">
                    </p>
                    <p>
                            <span>
                                身份证号
                            </span>
                        <input type="text" name="card" value="{$row.id_card_no}">
                    </p>
                <h4>
                    <input type="submit"  onclick="cardpost()" value="立即认证">
                    <!--                    <a href="#">遇到问题？</a>-->
                </h4>
                {else}
                    <p>
                            <span>
                                真实姓名
                            </span>
                        <input type="text" name="name" value="{$row.real_name}" readonly>
                    </p>
                    <p>
                            <span>
                                身份证号
                            </span>
                        <input type="text" name="card" value="{$row.id_card_no}" readonly>
                    </p>
                <h4><input type="submit" value="已认证" style=" background-color: #416bee;"></h4>
                {/if}
                </form>
            </div>
            <div class="inform-text">
                <form id="update_info" onsubmit="return false" action="##" method="post">
                    <p>
                            <span>
                                用户名
                            </span>
                        <input type="text" value="{$row.username}" readonly>
                    </p>
                    <p>
                            <span>
                                昵&nbsp;&nbsp;称
                            </span>
                        <input type="text" name="nickname" value="{$row.nickname}">
                    </p>
                    <p>
                            <span>
                                手机号
                            </span>
                        <input type="text" name="mobile" value="{$row.mobile}">
                    </p>
                    <p>
                            <span>
                                Q&nbsp;&nbsp;Q
                            </span>
                        <input type="text" name="qq" value="{$row.qq}">
                    </p>
                <h4>
                    <input type="submit" onclick="updateinfo()" value="确定修改">
                </h4>
                </form>
            </div>
            <div class="inform-text">
                <form id="update_pass" onsubmit="return false" action="##" method="post">
                    {:token()}
                <p>
        				<span>
        					旧密码
        				</span>
                    <input type="password" name="oldpassword" data-rule="required" placeholder="{:__('Old password')}">
                </p>
                <p>
        				<span>
        					新密码
        				</span>
                    <input type="password" name="newpassword" data-rule="required" placeholder="{:__('New password')}">
                </p>
                <p>
        				<span>
        					再次确认
        				</span>
                    <input type="password" name="renewpassword" data-rule="required" placeholder="{:__('Renew password')}">
                </p>
                <h4>
                    <input type="submit" onclick="updatepass()" value="确定修改">
                </h4>
                </form>
            </div>
        </div>
    </main>

</div><!--mobile_wrap-->
{include file="layout/footer" /}
</body>

<script type="text/javascript">
    //实名认证
    function cardpost() {
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "{:url('user/idcard')}" ,//url
            data: $('#renzheng').serialize(),
            success: function (result) {
                if (result.code == 0) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }else if (result.code == 1) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }else if (result.code == 2) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }else if (result.code == 3) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }
                ;

            },
            error : function() {
                new NoticeJs({
                    text: '异常',
                    position: 'middleCenter',
                }).show();
            }
        });
    }

    //信息修改
    function updateinfo() {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "{:url('user/update_info')}" ,
            data: $('#update_info').serialize(),
            success: function (result) {
                if (result.code == 11) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }else if (result.code == 12) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }
                ;

            },
            error : function() {
                new NoticeJs({
                    text: '异常',
                    position: 'middleCenter',
                }).show();
            }
        });
    }

    //密码修改
    function updatepass() {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "{:url('user/update_pass')}" ,
            data: $('#update_pass').serialize(),
            success: function (result) {
                if (result.code == 21) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }else if (result.code == 22) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }else if (result.code == 23) {
                    new NoticeJs({
                        text: result.msg,
                        position: 'middleCenter',
                        animation: {
                            open: 'animated bounceInRight',
                            close: 'animated bounceOutLeft'
                        }
                    }).show();
                }
                ;

            },
            error : function() {
                new NoticeJs({
                    text: '异常',
                    position: 'middleCenter',
                }).show();
            }
        });
    }
</script>

<script type="text/javascript">
    $('.inform-list ul li').click(function(){
        var n=$(this).index();
        $(this).addClass('acti').siblings().removeClass('acti');
        $('.inform-text').fadeOut();
        $('.inform-text').eq(n).fadeIn();
    })
</script>
</html>
